package com.example.myapplicationgit;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {
    Timer timer=new Timer();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       lll();
    }

    //跳转
    public void init(){
        TimerTask timerTask=new TimerTask() {
            @Override
            public void run() {
                Intent intent=new Intent(MainActivity.this,Main2Activity.class);
                startActivity(intent);
                MainActivity.this.finish();
            }
        };
        timer.schedule(timerTask,1000);
    }

    //判断是否是第一次进入
    public void lll(){
        SharedPreferences setting = getSharedPreferences("com.example.hr_jie", 0);
        Boolean user_first = setting.getBoolean("FIRST", true);
        if (user_first) {// 第一次则跳转到欢迎页面
            setting.edit().putBoolean("FIRST", false).commit();
            init();
        } else {//如果是第二次启动则直接跳转到主页面
            startActivity(new Intent(this,Main2Activity.class));}
    }

}
